package com.study.service.impl;

import com.study.bean.entity.DormitoryBuilding;
import com.study.bean.entity.StuCounter;
import com.study.bean.entity.Student;
import com.study.bean.query.BuildAdmin;
import com.study.bean.query.Rooms;
import com.study.bean.query.StudentQuery;
import com.study.bean.vo.StudentVO;
import com.study.dao.impl.StudentDaoImpl;
import com.study.service.StudentService;
import com.study.util.PageInfo;

import java.util.List;

public class StudentServiceImpl implements StudentService {
    private StudentDaoImpl studentDao = new StudentDaoImpl();

    public  StuCounter login(String sno, String password) {
          return studentDao.login(sno,password);
    }

    @Override
    public PageInfo selectByPage(StudentQuery studentQuery) {
        List<StudentVO> list = studentDao.selectByPage(studentQuery);
        //现在要搜索的是符合条件的总的数量
        int totalCount = studentDao.selectTotalCount(studentQuery);

        return PageInfo.ok(totalCount, list);
    }

    @Override
    public int delById( int id,int status) {

        int rs = studentDao.deleteById(id,status);
        return rs;
    }


    @Override
    public List<DormitoryBuilding> selectbuild() {
        return studentDao.selectbuild();
    }

    @Override
    public List<Rooms> selectRoom(int buildId) {


       List<Rooms> rooms =  studentDao.selectRoom(buildId);
       return rooms;
    }

    @Override
    public List<BuildAdmin> selectAdmin(int buildId) {

        List<BuildAdmin> buildAdmins = studentDao.selectAdmin(buildId);
        return buildAdmins;
    }

    @Override
    public StudentVO selectById(int i) {

        StudentVO studentVO = studentDao.selectById(i);
        return studentVO;
    }

    @Override
    public Boolean addStudent(Student student) {

        Integer i = studentDao.addStudent(student);
        if (i==1){
            return true;
        }
        return false;
    }

    @Override
    public Boolean updateStudent(Student student) {
        Integer i = studentDao.updateStudent(student);
        if (i==1){
            return true;
        }
        return false;
    }


}
